package com.bysj.lms;


import com.bysj.lms.pojo.entity.LmsFa;
import com.bysj.lms.utils.RedisUtil;
import org.springframework.data.redis.core.RedisTemplate;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class Test {
    public static void main(String[] args) {
        String s = "hello";
//        System.out.println(s[0]);
    }
}


class RunnableTest extends Thread {




    @Override
    public void run() {
        try {
            RedisTemplate<String, String> redisTemplate = new RedisTemplate<>();
            redisTemplate.opsForValue().set("timeOutKey", "timeOut", 5, TimeUnit.SECONDS);
            String timeOutValue = redisTemplate.opsForValue().get("timeOutKey")+"";
            System.out.println("通过set(K key, V value, long timeout, TimeUnit unit)方法设置过期时间，过期之前获取的数据:"+timeOutValue);

            Thread.sleep(5*1000);
            timeOutValue = redisTemplate.opsForValue().get("timeOutKey")+"";
            System.out.print(",等待10s过后，获取的值:"+timeOutValue);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}